package jp.sinya.db;

import java.io.InputStream;
import java.util.Properties;

public class DaoFactory {
    private static Properties properties = null;

    static {
        try {
            InputStream in = DaoFactory.class.getClassLoader().getResourceAsStream("dao.properties");
            properties = new Properties();
            properties.load(in);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static StudentDao getStudentDao() {
        String daoClassName = properties.getProperty("jp.sinya.db.StudentDao");
        try {
            Class clazz = Class.forName(daoClassName);
            return (StudentDao) clazz.newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
